<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$msg = array();

//权限验证
if( Role::init() == false ){
	$msg['error'] = false;
	$msg['string'] = '权限不足！';
	$myjson = json_encode($msg); 
	echo $myjson; 
	exit;
}

$db = new DB('news');

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

$category_sql = 'select id,title from categories where id='.$id.' and is_del=2 limit 1';
$category_rs = $db->query($category_sql)->getOne();

if( $category_rs['id'] <= 0 ){//id不存在
	$msg['error'] = false;
	$msg['string'] = '参数有误！';
}else{
	//更新is_del字段
	$data = array('is_del'=>3);
	$db->table('categories')->where('id='.$category_rs['id'])->update($data)->run();
	
	$msg['error'] = true;
	$msg['string'] = '成功彻底删除《'.$category_rs['title'].'》栏目!';
}
$myjson = json_encode($msg); 
echo $myjson; 